package ${controllerPackage};

import com.douya.common.pojo.dto.PagerDTO;
import com.douya.common.pojo.vo.CommonResponseVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import ${dtoPackage}.${class}DTO;
import ${voPackage}.${class}VO;
import ${servicePackage}.${class}Service;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 说明：${remarks}内部接口实现
 *
 * @author ${author}
 * @date ${date}
 */
@Slf4j
@Validated
@RestController
@RequestMapping("${controllerUrl}")
public class ${class}Controller {

    @Resource
    ${class}Service m${class}Service;

    /**
     * 分页获取${remarks}
     *
     * @param pager 分页条件
     * @return ${remarks}的分页信息
     */
    @GetMapping(value = "page")
    public CommonResponseVO${r'<'}IPage${r'<'}${class}VO>> page(PagerDTO pager) {
        return CommonResponseVO.success(m${class}Service.page(pager));
    }

    /**
     * 根据ID获取${remarks}
     *
     * @param id ID
     * @return ${remarks}
     */
    @GetMapping(value = "findById")
    public CommonResponseVO${r'<'}${class}VO> findById(@NotNull(message = "ID不能为空") Long id) {
        return CommonResponseVO.success(m${class}Service.findById(id));
    }

    /**
     * 新增/修改${remarks}
     *
     * @param ${name}DTO ${remarks}
     */
    @PostMapping(value = "insert")
    public CommonResponseVO${r'<'}?> insert(@Validated @RequestBody ${class}DTO ${name}DTO) {
        m${class}Service.insert(${name}DTO);
        return CommonResponseVO.success();
    }

    /**
     * 根据ID删除${remarks}
     *
     * @param id ID
     */
    @DeleteMapping(value = "delete")
    public CommonResponseVO${r'<'}?> delete(@NotNull(message = "ID不能为空") Long id) {
        m${class}Service.delete(id);
        return CommonResponseVO.success();
    }
}
